package com.dingreading.cloud.admin.util;

import com.dingreading.cloud.common.util.DateUtil;

import java.util.Date;

public class ContractFileUtil {

    private static final String KEY = "contract";

    /**
     * 合同文件访问token，30分钟后过期
     */
    public static String getToken(String ipAddr) {
        Date date = DateUtil.addMinutes(DateUtil.getNowDatetime(), 10);
        String expiryTime = DateUtil.getDefaultTimeStr(date) + "," + ipAddr;
        return "?token=" + RC4Util.encry_RC4_string(expiryTime, KEY);
    }

    /**
     * 解密token
     */
    public static String decryToken(String token) {
        return RC4Util.decry_RC4(token, KEY);
    }

}
